<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <title>Resader 后台管理系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <link rel="stylesheet" href="../amis/sdk.css" />
    <!-- 从 1.1.0 开始 sdk.css 将不支持 IE 11，如果要支持 IE11 请引用这个 css，并把前面那个删了 -->
    <!-- <link rel="stylesheet" href="sdk-ie11.css" /> -->
    <!-- 不过 amis 开发团队几乎没测试过 IE 11 下的效果，所以可能有细节功能用不了，如果发现请报 issue -->
    <style>
        html,
        body,
        .app-wrapper {
            position: relative;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
    <div id="root" class="app-wrapper"></div>

    <script src="../js/common.js"></script>
    <script src="../js/blueimp_md5.js"></script>
    <script src="../amis/sdk.js"></script>
    <script>
        (function () {
            var user = getUser(true);

            let amis = amisRequire('amis/embed');
            amis.embed('#root', {
                data: {
                    user: user
                },
                type: "page",
                title: "feed",
                body: [
                    {
                        label: "添加",
                        type: "button",
                        actionType: "dialog",
                        level: "primary",
                        className: "m-b-sm",
                        dialog: {
                            title: "添加 feed",
                            body: {
                                type: "form",
                                api: {
                                    method: "post",
                                    url: "./AddFeed?url=${url}",
                                    headers: {
                                        token: user.token
                                    }
                                },
                                controls: [
                                    {
                                        type: 'text',
                                        name: "url",
                                        label: "链接",
                                        width: 150,
                                        required: true
                                    }
                                ]
                            }
                        }
                    },
                    {
                        type: 'crud',
                        api: {
                            method: "get",
                            url: './feeds',
                            headers: {
                                token: user.token
                            }
                        },
                        syncLocation: false,
                        columns: [
                            {
                                type: "operation",
                                label: "操作",
                                width: 90,
                                buttons: [
                                    {
                                        label: "修改",
                                        type: "button",
                                        actionType: "drawer",
                                        drawer: {
                                            title: "修改 feed",
                                            body: {
                                                type: "form",
                                                api: {
                                                    method: "post",
                                                    url: "./updatefeed?id=${id}",
                                                    headers: {
                                                        token: user.token
                                                    }
                                                },
                                                controls: [
                                                    {
                                                        type: 'text',
                                                        name: "id",
                                                        label: "id",
                                                        disabled: true
                                                    },
                                                    {
                                                        type: 'text',
                                                        name: "url",
                                                        label: "Url",
                                                        disabled: true
                                                    },
                                                    {
                                                        type: 'text',
                                                        name: "title",
                                                        label: "标题"
                                                    },
                                                    {
                                                        type: 'text',
                                                        name: "description",
                                                        label: "描述"
                                                    },
                                                    {
                                                        type: 'text',
                                                        name: "image",
                                                        label: "Image"
                                                    },
                                                    {
                                                        type: 'text',
                                                        name: "label",
                                                        label: "标签"
                                                    },
                                                    {
                                                        type: 'text',
                                                        name: "createTime",
                                                        label: "创建时间",
                                                        disabled: true
                                                    },
                                                    {
                                                        type: 'text',
                                                        name: "updateTime",
                                                        label: "更新时间",
                                                        disabled: true
                                                    }]
                                            }
                                        }
                                    }
                                ]
                            },
                            {
                                type: 'text',
                                name: "id",
                                label: "id"
                            },
                            {
                                type: 'text',
                                name: "url",
                                label: "Url"
                            },
                            {
                                type: 'text',
                                name: "title",
                                label: "标题",
                                width: 150
                            },
                            {
                                type: 'text',
                                name: "description",
                                label: "描述"
                            },
                            {
                                type: 'text',
                                name: "image",
                                label: "Image"
                            },
                            {
                                type: 'text',
                                name: "label",
                                label: "标签"
                            },
                            {
                                type: 'text',
                                name: "createTime",
                                label: "创建时间"
                            },
                            {
                                type: 'text',
                                name: "updateTime",
                                label: "更新时间"
                            }
                        ]
                    }],
                aside: [
                    {
                        type: "nav",
                        stacked: true,
                        links: [
                            {
                                label: "home",
                                to: "index.html"
                            },
                            {
                                label: "feed",
                                to: "./feed.html",
                                active: true
                            },
                            {
                                label: "recommend",
                                to: "./recommend.html"
                            }
                        ]
                    }
                ]
            });
        })();
    </script>
</body>
</html>